package com.google.googlemarket;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import com.google.googlemarket.adapter.MyAdpter;
import com.google.googlemarket.fragement.AppFragment;
import com.google.googlemarket.fragement.HomeFragment;
import com.google.googlemarket.fragement.CategaryFragment;
import com.google.googlemarket.fragement.SubjectFragment;
import com.google.googlemarket.fragement.GameFragment;
import com.google.googlemarket.fragement.RecommendFragment;
import com.google.googlemarket.fragement.TopFragment;
import com.google.googlemarket.view.PagerTab;

import java.util.ArrayList;

public class MainActivity extends ActionBarActivity {

    private PagerTab pager_tab;
    private ViewPager view_pager;
private ArrayList<Fragment> mFragments;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        pager_tab = (PagerTab) findViewById(R.id.pager_tab);
        view_pager = (ViewPager) findViewById(R.id.view_pager);
        mFragments = new ArrayList<>();
        mFragments.add(new HomeFragment());
        mFragments.add(new AppFragment());
        mFragments.add(new GameFragment());
        mFragments.add(new SubjectFragment());
        mFragments.add(new RecommendFragment());
        mFragments.add(new CategaryFragment());
        mFragments.add(new TopFragment());
        PagerAdapter adapter = new MyAdpter(getSupportFragmentManager(),mFragments);
        view_pager.setAdapter(adapter);
        view_pager.setOffscreenPageLimit(mFragments.size());
        pager_tab.setViewPager(view_pager);
    }
}
